<%--
  Created by IntelliJ IDEA.
  User: dqf
  Date: 2015/3/9
  Time: 15:35
  To change this template use File | Settings | File Templates.
--%>
<%@ page language="java" pageEncoding="UTF-8"%>
<%@taglib prefix="s" uri="/struts-tags"%>
<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://"
            + request.getServerName() + ":" + request.getServerPort()
            + path + "/";
%>
<style>
    div.pull-right{
        margin-top:-2px;
        margin-right:-86px
    }
</style>
<div class="row">
    <!-- NEW WIDGET START -->
    <article class="col-sm-12 col-md-12 col-lg-12">
        <div class="jarviswidget well" id="wid-id-3"
             data-widget-colorbutton="false"
             data-widget-editbutton="false"
             data-widget-togglebutton="false"
             data-widget-deletebutton="false"
             data-widget-fullscreenbutton="false"
             data-widget-custombutton="false"
             data-widget-sortable="false">
            <!-- widget div-->
            <div>
                <div class="widget-body">
                    <a class="btn btn-default" id="btn-re-common" href="javascript:void(0)">
                        <i class="fa fa-lg fa-mail-reply-all"></i>知识共享
                    </a>
                    <shiro:hasAnyRoles name="wechat">
                    <a class="btn btn-default pull-right pull-right-fix" key="ajax_edit" href="javascript:void(0);"><i class="fa fa-lg fa-edit"></i> 编辑</a>
                    <a class="btn btn-default pull-right pull-right-fix" id="btn-knowledge-comment" href="javascript:void(0);"><i class="fa fa-lg fa-comment-o"></i> 批注</a>
                    </shiro:hasAnyRoles>
                        <hr class="simple">

                    <ul id="myTab1" class="nav nav-tabs bordered  ">
                        <li class="active">
                            <a href="#s1" data-toggle="tab"><i class="fa fa-fw fa-lg fa-credit-card"></i> 基本信息   </a>
                        </li>
                        <li>
                            <a href="#s2" id="linkman_title" data-toggle="tab"><i class="fa fa-fw fa-lg fa-users"></i> 图文说明 </a>
                        </li>

                    </ul>
                    <div id="myTabContent1" class="tab-content padding-10 ">
                        <div class="tab-pane fade in active " id="s1" style="margin: 10px;">
                            <div>
                                <form id="knowledge" class="smart-form" novalidate="novalidate" action="" method="post">
                                    <input type="hidden" name="keyId" id="keyId" value="<s:property value="knowledge.id" />"/>
                                    <input type="hidden" name="createrId" id="createrId" value="<s:property value="knowledge.creater.id" />">
                                    <input type="hidden" name="creater" id="creater" value="<s:property value="knowledge.creater.name"/>">
                                    <header id="textTitle" style="display: block;">
                                        知识共享
                                    </header>
                                    <fieldset>
                                        <div class="row">
                                            <label class="label col col-2">
                                                <i class="fa fa-asterisk txt-color-red"></i>
                                                知识大类别
                                            </label>
                                            <section class="col col-5">
                                                <label class="input state-disabled">
                                                    <input type="text" name="superType" id="superType" value="<s:property value="knowledge.superType.name"/>" disabled>
                                                </label>
                                            </section>
                                        </div>
                                        <div class="row">
                                            <label class="label col col-2">
                                                <i class="fa fa-asterisk txt-color-red"></i>
                                                知识小类别
                                            </label>
                                            <section class="col col-5">
                                                <label class="input state-disabled">
                                                    <input type="text" name="subType" id="subType" value="<s:property value="knowledge.subType.name"/>" disabled>
                                                </label>
                                            </section>
                                        </div>
                                        <div class="row">
                                            <label class="label col col-2">
                                                <i class="fa fa-asterisk txt-color-red"></i>
                                                知识标题
                                            </label>
                                            <section class="col col-5">
                                                <label class="input state-disabled">
                                                    <input type="text" name="title" id="title" placeholder="" value="<s:property value="knowledge.name"/>" disabled>
                                                </label>
                                            </section>
                                        </div>
                                        <div class="row">
                                            <label class="label col col-2">文件上传</label>
                                            <section class="col col-5">
                                                <label class="input state-disabled">

                                                    <input  name="uploadify" id="filename" placeholder="" style="display: none" value="<s:property value="knowledge.knowledgeId"/>">
                                                </label>
                                            </section>
                                        </div>
                                    </fieldset>
                                </form>
                            </div>
                        </div>
                        <div class="tab-pane fade in " id="s2" style="margin: 10px">
                            <fieldset>
                                <s:property escape='0' value="knowledge.contextHtml" />
                            </fieldset>
                        </div>

                    </div>
                </div>
            </div>
        </div>
    </article>
</div>


<script type="text/javascript">
    //上传文件
    readLoad({
        objId:"filename",
        entityName:"knowledgeId",
        sourceId:"filename"
    });

    //编辑
    $("a[key=ajax_edit]").click(function(){
        loadURL("ajax-knowledge!input.action?keyId="+$("input#keyId").val(),$('#content'));
    });

    //返回视图
    $("#btn-re-common").click(function(){
        loadURL("ajax!knowledge.action",$('#content'));
    });

    $("#btn-knowledge-comment").off("click").on("click",function(){
        var actionUrl = "ajax-comment!list.action";
        var id = $("form#knowledge input#keyId").val();
        var data = {keyId:id};
        $(this).leftview('init',{
            title:"批注信息",
            actionUrl:actionUrl,
            data:data
        });
        $(this).leftview('foot',{callback:common_click});
    });

    function common_click(){
        $("#left_foot_btn_comment").off("click").on("click",function(){
            var actionUrl = "ajax-comment!save.action";
            var id = $("form#knowledge input#keyId").val();
            var text = $("#chat_textarea-expand").val();
            var createrId = $("#createrId").val();
            var parentId = $("#chat_keyId li:first").attr("id");
            var data = {
                targetId:id,
                parentId:parentId,
                text:text,
                toUsersId:createrId,
                targetObject:"com.joint.core.entity.Knowledge"
            };
            ajax_action(actionUrl,data,null,function(data){
                _show(data);
                $(this).leftview('leftClose');
            });
        })
    }

</script>